import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path"

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  plugins: [vue()],
  //服务配置
  server:{
    host:true,   //监听所有地址
    port:8080,   //端口配置
    open:true,    //默认浏览器打开
    cors: true,
    proxy: {
      '/api': {
        // 目标服务器的地址
        target: 'https://apple.tools.orgpeel.cn/api',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }


 },
  // 配置 @ 符号
  resolve: {
    alias: {
      "@": resolve(__dirname, "src")
    }
  },
  build: {
    minify: "terser",
    terserOptions: {
        compress: {
            drop_console: true,
            drop_debugger: true,
        },
    },
    rollupOptions: { // 自定义Rollup的选项      
      output: {
        entryFileNames: 'assets/js/[name]-[hash].js', // 指定 JS 文件的输出路径及命名规则
        chunkFileNames: 'assets/js/[name]-[hash].js', // 指定分片文件的输出路径及命名规则
        assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
      },
    },
  },
})
